[6.2] Use default libcurl receive buffer size - #5522
Open
pepicrft wants to merge 1 commit into
Open
Conversation
pepicrft
marked this pull request as ready for review
July 23, 2026 11:26
Contributor
|
As far as I'm aware there are no plans to ship a new 6.2.x Swift toolchain. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This backports #5448 to
release/6.2.Foundation Networking no longer overrides libcurl's receive buffer size when configuring web and file-transfer requests. Both protocols now use libcurl's default receive buffer size.
Why
Swift Package Manager can issue more concurrent registry downloads than the per-host connection limit. Registry archives are served through redirects, so Foundation Networking reuses an existing libcurl handle for the redirected request.
With Swift 6.2 on Linux, that combination can terminate
swift package resolvewith libcurl error 43. The fix is already present onmain, but Swift 6.2.4 was released before it merged.Root cause
The Swift 6.2 implementation reapplies
CURLOPT_BUFFERSIZEevery time_HTTPURLProtocolor_FTPURLProtocolconfigures a transfer. curl 8.5.0 can reject that operation withCURLE_BAD_FUNCTION_ARGUMENTwhen the reused handle still owns its receive buffer.Foundation Networking treats the returned error as a programming error through
try!, so the package-resolution process traps instead of reporting a recoverable download failure.Approach
Remove the explicit buffer-size assignments and let libcurl retain its default. This matches the accepted fix in #5448.
The removed value was capped to
CURL_MAX_WRITE_SIZE, which is also libcurl's default receive buffer size, so this avoids the unsafe reconfiguration without changing the effective buffer size.Impact
Swift Package Manager registry resolution no longer crashes when concurrent package downloads cross redirects on affected Linux distributions. File-transfer requests also stop applying the same unsafe override.
Reproduction
The failure can be reproduced with Swift Package Manager and the Swift 6.2 container:
Before this backport, the command terminates in
_HTTPURLProtocol.configureEasyHandleduring redirect handling:Validation
release/6.2source with the coordinated Swift 6.2.4 dependency revisions.swift test --filter TestURLSession/test_httpRedirectionWithCode303. The targeted redirect test passed.